<!doctype html>
<html class="no-js fixed-layout">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>首页</title>
  <meta name="description" content="index">
  <meta name="keywords" content="index">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="/static/assets/i/favicon.png">
  <link rel="apple-touch-icon-precomposed" href="/static/assets/i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="/static/assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="/static/assets/css/admin.css">
  <style type="text/css">
    .lable_style{
      width: 49%;
      display: inline-flex;
      margin-top: 10px !important;
      background-color: #f9f9f9;
    }
  </style>
</head>
<body>



  <div class="admin-content">

    <div class="admin-content-body">

      <div class="am-g">


        
        <div class="am-u-sm-12 am-u-md-12 ">
          <!--中间侧块 注意下面是form表-->
            <input id="disease_id" style="display: none;" value={{ diseaseId }}></input>
          <div id = 'param' class="am-u-sm-12">
            <strong>桥面铺装</strong>
            <br>
            {% for i in deckPavement %}
            <label class="am-checkbox am-success lable_style"><input type="checkbox" value="{{ i.id }}" data-am-ucheck> {{ i.name }}</label>
            {% endfor %}   
            <br>
            <strong>桥墩/桥台材料</strong>
            <br>
            {% for i in material %}
            <label class="am-checkbox am-success lable_style"><input type="checkbox" value="{{ i.id }}" data-am-ucheck> {{ i.name }}</label>
            {% endfor %} 
            <br>
            <strong>上部结构材料</strong>
            <br>
            {% for i in upperMaterial %}
            <label class="am-checkbox am-success lable_style"><input type="checkbox" value="{{ i.id }}" data-am-ucheck> {{ i.name }}</label>
            {% endfor %} 
            <br>
            <strong>基础材料</strong>
            <br>
            {% for i in towerBasisMaterial %}
            <label class="am-checkbox am-success lable_style"><input type="checkbox" value="{{ i.id }}" data-am-ucheck> {{ i.name }}</label>
            {% endfor %} 
            <br>
            <strong>桥塔材料</strong>
            <br>
            {% for i in towerMaterial %}
            <label class="am-checkbox am-success lable_style"><input type="checkbox" value="{{ i.id }}" data-am-ucheck> {{ i.name }}</label>
            {% endfor %} 
          </div>

          
        </div>
        <div class="am-u-sm-12 am-u-md-6">
          <div class="am-btn-toolbar">

            <div class="am-margin" style="padding: 0 250px">
              <button type="button" class="am-btn am-btn-primary am-btn-xs" onclick="param_submit()">保存</button>
            </div>


          </div>
        </div>

      </div>
    </div>

  </div>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/static/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/static/assets/js/amazeui.min.js"></script>
<script src="/static/assets/js/amazeui.tree.js"></script>
<script src="/static/assets/datatables/amazeui.datatables.min.js"></script>
<script src="/static/assets/dialog/amazeui.dialog.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/assets/css/amazeui.tree.css" />
<script src="/static/assets/js/app.js"></script>
<script type="text/javascript">

$(document).ready(function(){

  var disease_id = document.getElementById("disease_id").value;
      $.ajax({
      "url":"/QLXJ_YSGL_BHCL_CLSEL/?disease_id="+disease_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        
        if (data.status == 1) {
          $("#param input").each(function() {
            for(var i=0;i<data.data.length;i++){
              if($(this).val()==data.data[i].param_id){ 
                $(this).prop('checked',true);
              };
            }
          })
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("读取权限失败！")
      });
})


function param_submit(){
  var disease_id = document.getElementById("disease_id").value;
    var param_ids = "";
    $("#param input").each(function() {
      if ($(this).prop('checked')==true) {
        b = $(this).val();
        if(param_ids == ""){
          param_ids = param_ids + b;
        }else{
          param_ids = param_ids + '|' + b;
        }
        
      }
    }); 
    $.ajax({
      "url":"/QLXJ_YSGL_BHCL_SAVE/?disease_id="+disease_id+"&param_ids="+param_ids+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          var index = parent.layer.getFrameIndex(window.name);
          parent.location.reload();
          parent.layer.close(index);
          //window.close();
          //layer.closeAll();
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("保存失败！")
      });
  
}


var AlertMSG=function(msg){
    AMUI.dialog.alert({ title: '错误提示', content: msg, onConfirm: function() { console.log('close'); } });
}
</script>
</body>

</html>